﻿using System;
using Reflector;
using Reflector.CodeModel;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Collections;
using System.IO;

internal class SeqGenerator : IPackage
{
    //Reflector related members
    private IWindowManager windowManager;
    private ICommandBarManager commandbarManager = null;
    private ICommandBarButton menuBarButton = null;
    private ICommandBarButton menuBarPreprocessButton = null;
    private ICommandBarSeparator menuBarSeparator = null;
    private EventHandler evtSearch = null;
    private EventHandler evtSearchPreprocess = null;
    private IServiceProvider serviceProvider;
    private ITranslatorManager translatorManager;
    private IAssemblyManager assemblyManager = null;

    public void Load(IServiceProvider serviceProvider)
    {
        this.serviceProvider = serviceProvider;
        this.windowManager = (IWindowManager)serviceProvider.GetService(typeof(IWindowManager));
        this.commandbarManager = (ICommandBarManager)serviceProvider.GetService(typeof(ICommandBarManager));
        this.translatorManager = (ITranslatorManager)serviceProvider.GetService(typeof(ITranslatorManager));
        this.assemblyManager = (IAssemblyManager)serviceProvider.GetService(typeof(IAssemblyManager));

        evtSearch = new EventHandler(this.SequenceGenButton_Click);
        this.menuBarSeparator = commandbarManager.CommandBars["Tools"].Items.AddSeparator();
        this.menuBarButton = commandbarManager.CommandBars["Tools"].Items.AddButton("Generate Sequence", null, evtSearch);
    }

    public void Unload()
    {
        this.commandbarManager.CommandBars["Tools"].Items.Remove(this.menuBarButton);
        this.commandbarManager.CommandBars["Tools"].Items.Remove(this.menuBarPreprocessButton);
        this.commandbarManager.CommandBars["Tools"].Items.Remove(this.menuBarSeparator);
    }

    private void SequenceGenButton_Click(object sender, EventArgs e)
    {
        this.windowManager.ShowMessage("Unloading HelloWorld!");
    }
}